<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>投递的岗位</title>
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>

    <link rel="stylesheet" href="../js/libs/sui/sm.min.css">
    <link rel="stylesheet" href="../js/libs/sui/sm-extend.min.css">
    <link rel="stylesheet" href="../iconfont/iconfont.css">
    <link rel="stylesheet" href="../less/main.css"/>

    <script type="text/javascript" src='../js/libs/jquery-3.1.0.min.js' charset='utf-8'></script>
    <script type="text/javascript">
        var Zepto = jQuery;
    </script>
    <script type="text/javascript" src='../js/libs/sui/sm.js' charset='utf-8'></script>
    <script type="text/javascript" src='../js/libs/sui/sm-extend.min.js' charset='utf-8'></script>
    <script type="text/javascript" src="../js/libs/juicer-min.js"></script>
    <script type="text/javascript" src="../js/libs/jquery.md5.js"></script>
    <script type="text/javascript" src="../js/api.js"></script>
    <script type="text/javascript" src="../js/utils.js"></script>
    <script type="text/javascript" src="../js/common.js"></script>
</head>
<body>
<!-- 这里是页面内容区 -->
<div class="page">
    <!-- 头部-->
    <div class="head-no-toolbar bg-self-green no-left-icon">
        <span class="icon iconfont c-white p-l" onclick="javascript:api.closeWin();">&#xe61f;</span>
        <span class="c-white t-center">已投简历的岗位</span>
    </div>

    <div class="content pull-to-refresh-content t-0" data-ptr-distance="20">
        <div class="pull-to-refresh-layer">
            <div class="preloader"></div>
            <div class="pull-to-refresh-arrow"></div>
        </div>
        <div class="focus-position">

            <!--<div class="list-block media-list bg-white">-->
            <!--<ul>-->
            <!--<li>-->
            <!--<div class="item-inner">-->
            <!--<div class="item-title-row">-->
            <!--<div class="item-title">Java软件工程师</div>-->
            <!--<div class="item-after f-little">今天</div>-->
            <!--</div>-->
            <!--<div class="item-title-row">-->
            <!--<div class="item-subtitle">贵州安云科技有限公司</div>-->
            <!--<div class="item-after f-little">6千-8千</div>-->
            <!--</div>-->
            <!--<div class="f-little">-->
            <!--<span class="m-r"><i class="iconfont icon employ-icon">-->
            <!--&#xe614;</i><span>贵阳</span></span>-->
            <!--<span class="m-r"><i class="iconfont icon employ-icon">-->
            <!--&#xe61a;</i><span>学历不限</span></span>-->
            <!--</div>-->
            <!--<div class="item-foot1">-->
            <!--<a class="cancel"><i class="icon iconfont">&#xe61c;</i>取消关注</a>-->

            <!--<div class="pull-right">-->
            <!--<a href="" class="my-position-info">查看详细 <span class="icon iconfont">&#xe620;</span></a>-->
            <!--</div>-->
            <!--</div>-->
            <!--</div>-->
            <!--</li>-->
            <!--</ul>-->
            <!--</div>-->
            <!--<div class="list-block media-list bg-white">-->
            <!--<ul>-->
            <!--<li>-->
            <!--<div class="item-inner">-->
            <!--<div class="item-title-row">-->
            <!--<div class="item-title">Java软件工程师</div>-->
            <!--<div class="item-after f-little">今天</div>-->
            <!--</div>-->
            <!--<div class="item-title-row">-->
            <!--<div class="item-subtitle">贵州安云科技有限公司</div>-->
            <!--<div class="item-after f-little">6千-8千</div>-->
            <!--</div>-->
            <!--<div class="f-little">-->
            <!--<span class="m-r"><i class="iconfont icon employ-icon">-->
            <!--&#xe614;</i><span>贵阳</span></span>-->
            <!--<span class="m-r"><i class="iconfont icon employ-icon">-->
            <!--&#xe61a;</i><span>学历不限</span></span>-->
            <!--</div>-->
            <!--<div class="item-foot1">-->
            <!--<a class="cancel"><i class="icon iconfont">&#xe61c;</i>取消关注</a>-->

            <!--<div class="pull-right">-->
            <!--<a href="" class="my-position-info">查看详细 <span class="icon iconfont">&#xe620;</span></a>-->
            <!--</div>-->
            <!--</div>-->
            <!--</div>-->
            <!--</li>-->
            <!--</ul>-->
            <!--</div>-->

        </div>
    </div>
</div>
<script id="focus-resume-tpl" type="text/template">
    {@each resumeList as it,index}
    <div class="list-block media-list bg-white">
        <ul>
            <li>
                <div class="item-inner">
                    <div data-unit-id="&{it.UNIT_ID}" data-post-id="&{it.POST_ID}" data-unit-name="&{it.UNIT_NAME}"
                         data-unit-addr="&{it.UNIT_ADDR}" class="my-focus-position">
                        <div class="item-title-row">
                            {@if (it.POST_NAME != null) && (it.POST_NAME != '')}
                            <div class="item-title">&{it.POST_NAME}</div>
                            {@/if}

                            {@if (it.APPLY_DATE != null) && (it.APPLY_DATE != '')}
                            <div class="item-after f-little">&{it.APPLY_DATE}</div>
                            {@/if}
                        </div>
                        <div class="item-title-row">
                            {@if (it.UNIT_NAME != null) && (it.UNIT_NAME != '')}
                            <div class="item-subtitle">&{it.UNIT_NAME}</div>
                            {@/if}

                            {@if (it.PAY_REMARKS != null) && (it.PAY_REMARKS != '')}
                            <div class="item-after f-little">&{it.PAY_REMARKS}</div>
                            {@/if}
                        </div>
                        <div class="f-little">
                            {@if (it.LOCATION != null) && (it.LOCATION != '')}
                            <span class="m-r"><i
                                    class="iconfont icon employ-icon">&#xe614;</i><span>&{it.LOCATION}</span></span>
                            {@/if}

                            {@if (it.EDUCATION_REQ != null) && (it.EDUCATION_REQ != '')}
                            <span class="m-r"><i
                                    class="iconfont icon employ-icon">&#xe61a;</i><span>&{it.EDUCATION_REQ}</span></span>
                            {@/if}
                        </div>
                    </div>
                    <div class="item-foot1">
                        <a data-apply-id="&{it.APPLY_ID}" class="cancel"><i class="icon iconfont">&#xe61c;</i>取消投递</a>

                        <div class="pull-right">
                            <a data-unit-id="&{it.UNIT_ID}" data-post-id="&{it.POST_ID}" data-unit-name="&{it.UNIT_NAME}" data-unit-addr="&{it.UNIT_ADDR}" class="my-position-info my-focus-position">查看详细<span class="icon iconfont">&#xe620;</span></a>
                        </div>
                    </div>
                </div>
            </li>
        </ul>
    </div>
    {@/each}

</script>
<script type="text/javascript">
    apiready = function () {
        juicer.set({
            'tag::operationOpen': '{@',
            'tag::operationClose': '}',
            'tag::interpolateOpen': '&{',
            'tag::interpolateClose': '}',
            'tag::noneencodeOpen': '$${',
            'tag::noneencodeClose': '}',
            'tag::commentOpen': '{#',
            'tag::commentClose': '}',
            'strip': false,
            'cache': false
        });

        var stuInfo = getLoginStudentInfo();
        var studentId = stuInfo.STUDENT_ID;
        //查询已投简历的岗位
        var sql = "SELECT " +
                "T1.APPLY_ID," +
                "T2.UNIT_ID," +
                "T2.UNIT_NAME," +
                "T2.UNIT_ADDR," +
                "T3.POST_ID," +
                "T3.LOCATION," +
                "T3.RECRUIT_CNT," +
                "T3.PAY_REMARKS," +
                "T3.POST_NAME," +
                "T3.EDUCATION_REQ," +
                "T1.APPLY_DATE" +
                " FROM " +
                "(" +
                "SELECT " +
                "T1.STUDENT_ID," +
                "T2.APPLY_ID," +
                "T2.UNIT_ID," +
                "T2.POST_ID," +
                "T2.APPLY_DATE" +
                " FROM " +
                "E_RESUME T1," +
                "E_APPLY_POST T2" +
                " WHERE " +
                " T1.STUDENT_ID = T2.STUDENT_ID" +
                " AND T2.STATE = '2'" +
                " AND T1.STUDENT_ID = '{0}'" +
                ") T1" +
                " LEFT JOIN E_COOPERATION_UNIT T2 ON T1.UNIT_ID = T2.UNIT_ID" +
                " LEFT JOIN E_RECRUIT_POST T3 ON T1.POST_ID = T3.POST_ID";
        var page = 1;

        getData(true);

        //获取投递数据
        function getData(progressFlag) {
            if (isObject(stuInfo)) {
                dbQuery(page, 10, sql.format(studentId), progressFlag, function (ret, err) {
                    if (isObject(ret) && ret.statusCode == 0) {
                        if (ret.result.length != 0) {
                            var resumeData = {resumeList: ret.result};

                            $(".focus-position").html(juicer($("#focus-resume-tpl").html(), resumeData));
                        } else {
                            toast("暂无已投简历的岗位");
                        }
                    }
                });
            }
        }

        // 下拉刷新已投递岗位
        $(document).on("refresh", ".pull-to-refresh-content", function () {
            if (isObject(stuInfo) && isNumber(studentId)) {
                page++;
                // 获取就业单位
                dbQuery(page, 10, sql.format(studentId), false, function (ret, err) {
                    if (isObject(ret) && (ret.statusCode == 0)) {
                        var resumeData = {resumeList: ret.result};
                        if (resumeData.resumeList.length > 0) {
                            $(".focus-position").html(juicer($("#focus-resume-tpl").html(), resumeData));
                        } else {
                            toast("已加载完毕");

                            page--;
                        }
                    }

                    $.pullToRefreshDone(".pull-to-refresh-content");
                });
            }
        });


        //点击item 或 查看详细 进入详细页面
        $(".focus-position").on("click", ".my-focus-position", function () {
            var $this = $(this);
            openWin("career-detail", "career-detail.html", {
                unitId: $this.data("unitId"),
                postId: $this.data("postId"),
                unitName: $this.data("unitName"),
                unitAddr: $this.data("unitAddr")
            });
        });

        //取消岗位投递
        function cancelFocus(applyId) {
            var sql = "UPDATE E_APPLY_POST T SET T.STATE = '3', T.CANCEL_DATE = NOW() WHERE T.APPLY_ID='{0}'";
            dbExecute(sql.format(applyId), false, function (ret, err) {
                if (isObject(ret) && ret.statusCode == 0) {
                    toast("取消投递成功");

                    //刷新页面
                    location.reload();
                }
            });
        }

        //取消投递
        $(".focus-position").on("click", ".cancel", function () {
            var $this = $(this);
            var applyId = $this.data("applyId");

            cancelFocus(applyId);
        });

        //接收 关注事件 并刷新页面
        api.addEventListener({name: "resumeEvent"}, function (ret, err) {
            location.reload();
        });
    };
</script>
<script>$.init();</script>
</body>
</html>
